<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon-precomposed" href="../images/apple-touch-icon.png">
    <title>charts-pie-simple</title>
    <link rel="stylesheet" href="../scripts/lib/seedsui/seedsui.min.css">
</head>
<body>
    <header>
        <div class="titlebar">
            <a class="titlebar-button" href="javascript:back()"><i class="size16 icon icon-arrowleft"></i></a>
            <h1 class="titlebar-title">简单饼图</h1>
        </div>
    </header>
    <article>
	   <div id="ID-ChartPie" style="width: 100%;height:300px;"></div>
    </article>
	<script src="../scripts/lib/seedsui/seedsui.min.js"></script>
	<script src="../scripts/lib/echarts/echarts.min.js"></script>
    <!--Exmobi能力-->
    <!--<script src="../scripts/lib/exmobi/exmobi.js"></script>-->
    <script>
        var view={
            /*=========================
              Model
              ===========================*/
            initialize:function(){
                /*Data*/
                //数据
                this.chartPieData=[
                    {value:"18",name:"未完成的问题",selected:true},
                    {value:"65",name:"已完成的问题"},
                ];
                //提示信息
                this.chartPieTip="{a} <br/>{b} : {c} ({d}%)"//{a}: series[].name ,{b}: series[].data[].name , {c}: series[].data[].value ,{d}: 占比
                //色轮
                this.colorList=['#53c6fd','#ffae02','#3ae3ea','#ff6f36','#cf7af3','#4cd32e','#4587f7','#00c2eb','#ff618f','#21d9a1'];

                /*DOM*/
                this.divChartPie=document.getElementById("ID-ChartPie");
                this.chartPie={};

                /*Render*/
                this.render();

                /*Events*/
                this._attach();
            },
            render:function(){
                this._initPlugin();
            },
            /*=========================
              Method
              ===========================*/
            _initChartPie:function(){
                var self=this;
                this.chartPie = echarts.init(this.divChartPie);
                
                this.chartPieOption = {
                    /*系列*/
                    series : [
                    {
                        name:"访问来源",
                        type:"pie",
                        radius:"60%",
                        label: {
                            normal: {
                                formatter: '{d}%',
                                position: 'inner'//文字在中央
                            }
                        },
                        center: ['50%', '40%'],
                        itemStyle: {//type为bar时,设置柱的颜色
                            normal: {
                                color: function(params) {
                                    return self.colorList[params.dataIndex];
                                }
                            }
                        },
                        data : this.chartPieData
                    }
                    ]
                }
                this.chartPie.setOption(this.chartPieOption);
            },
            /*=========================
              Plugin
              ===========================*/
            _initPlugin:function(){
                this._initChartPie();
            },
            /*=========================
              Events
              ===========================*/
            _attach:function(e){
                var self=this;
                this.chartPie.on("click",function(e){
                    self._onClickChartPie(e);
                });
            },
            _onClickChartPie:function(e){
                console.log(e);
            },
            /*=========================
              Event Handler
              ===========================*/
            /*=========================
              OnLoad
              ===========================*/
            _onLoad:function(){
                var self=this;
                //DOM

                //Plugin
                this._initPlugin();
                //Events
                this._attach();
            }
        }

        window.addEventListener("load",function(){
            view.initialize();
        }, false);
        //定义exmobi返回
        function back(){history.go(-1);}
    </script>
</body>
</html>